<template>
  <div class="about">
    <div style="text-align: center; padding: 50px;">
      <h1>这里是关于页面, 我并不想介绍自己</h1>
      <br>
      <Input v-model="content" placeholder="请输入内容..." style="width: 300px" />
      <Button type="success" @click="setContent">写文件</Button>
      <Button type="warning" @click="getContent">读文件</Button>
    </div>


  </div>
</template>
<script>
   import {get} from '../lib/http';
    export default {
        name: 'about',
        data(){
           return{
               content: ""
           }
        },
        methods: {
            async getContent(){
                let result = await get("static/token.json");
                console.log(result);
            },
            setContent(){
                let name = "test.json";
                let data = "sdflkajdlfasd";
                let urlObject = window.URL || window.webkitURL || window;
                let export_blob = new Blob([data]);
                let save_link = document.createElementNS("http://www.w3.org/1999/xhtml", "a");
                save_link.href = urlObject.createObjectURL(export_blob);
                save_link.download = name;
                this.fake_click(save_link);
            },
            fake_click(obj) {
                var ev = document.createEvent("MouseEvents");
                ev.initMouseEvent(
                    "click", true, false, window, 0, 0, 0, 0, 0
                    , false, false, false, false, 0, null
                );
                obj.dispatchEvent(ev);
            }
        }
    }
</script>
